﻿using Huayou.Common.Database;
    using Huayou.Utils;
    using HySoft.Cash.BaseClass;
    using HySoft.Cash.Structure;
    using System;
    using System.Data;

namespace HySoft.Cash.DB
{
    public class TStatementDB: BaseDB
    {


        public TStatementDB(DBOperate oper)
            : base(oper)
        {
        }


        public TStatementDT Get(int Sid)
        {
            TStatementDT tdt = new TStatementDT();

            try
            {
                string strSql = string.Format("select {0} from tStatementMaster where ID={1}", TStatementDT.allFields, Sid);
                DataTable table = base.ExecuteForDataTable(strSql);
                DataRow row = null;
                if (table.Rows.Count >= 0)
                {
                    row = table.Rows[0];
                    tdt = TStatementDT.ConvertFrom(row);
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return tdt;
        }

        public TStatementDT Get(Guid statementGuid)
        {
            TStatementDT tdt = new TStatementDT();

            try
            {
                string strSql = string.Format("select {0} from tStatementMaster where Guid='{1}'", TStatementDT.allFields, statementGuid);
                DataTable table = base.ExecuteForDataTable(strSql);
                DataRow row = null;
                if (table.Rows.Count >= 0)
                {
                    row = table.Rows[0];
                    tdt = TStatementDT.ConvertFrom(row);
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return tdt;
        }
    }
}
